Optimizing Performance with React.memo

Wrap components in React.memo to avoid unnecessary re-renders.


function MyComponent(props) {
    // logic goes here
}

export default React.memo(MyComponent);

This will Prevent unnecessary re-renders using React.memo.

For More details check this blog.

You Might Also Like

Simplify Context Usage with a Custom Hook

Instead of using useContext directly every time, create a custom hook: **1. Define the Context and...

Default Props for Components

This code sets a default value for the text prop in the Button component. If no text prop is provide...